#include <stdio.h>

/*
 * 在线进制转换
 * https://lostphp.com/hexconvert/
 */

double f(double a, double b)
{
	return a / 3.14 + b * 4.1;
}

int main()
{
	printf("%f\n", f(1.2, 3.4));
}

#if 0

/*
 * intel
 */
0000000000001149 <f>:
    1149:	f3 0f 1e fa          	endbr64 
    114d:	55                   	push   %rbp
    114e:	48 89 e5             	mov    %rsp,%rbp
    1151:	f2 0f 11 45 f8       	movsd  %xmm0,-0x8(%rbp)		// rbp-0x8=xmm0=a
    1156:	f2 0f 11 4d f0       	movsd  %xmm1,-0x10(%rbp)	// rbp-0x10=xmm1=b
    115b:	f2 0f 10 45 f8       	movsd  -0x8(%rbp),%xmm0		// xmm0=rbp-0x8
    1160:	f2 0f 10 0d a8 0e 00 	movsd  0xea8(%rip),%xmm1        # 2010 <_IO_stdin_used+0x10> xmm1=rip+0xea8=3.14
    1167:	00 
    1168:	f2 0f 5e c1          	divsd  %xmm1,%xmm0			// xmm0=a/xmm1
    116c:	66 0f 28 c8          	movapd %xmm0,%xmm1			// xmm1=xmm0,把源存储器内容值送入目的寄存器,当有m128时,必须对齐内存16字节.
    1170:	f2 0f 10 55 f0       	movsd  -0x10(%rbp),%xmm2	// xmm2=rbp-0x10=b
    1175:	f2 0f 10 05 9b 0e 00 	movsd  0xe9b(%rip),%xmm0        # 2018 <_IO_stdin_used+0x18> xmm0=rip+0xe9b=4.1
    117c:	00 
    117d:	f2 0f 59 c2          	mulsd  %xmm2,%xmm0			// xmm0*=xmm2
    1181:	f2 0f 58 c1          	addsd  %xmm1,%xmm0			// xmm0+=xmm1
    1185:	5d                   	pop    %rbp
    1186:	c3                   	retq   

0000000000001187 <main>:
    1187:	f3 0f 1e fa          	endbr64 
    118b:	55                   	push   %rbp
    118c:	48 89 e5             	mov    %rsp,%rbp
    118f:	f2 0f 10 05 89 0e 00 	movsd  0xe89(%rip),%xmm0        # 2020 <_IO_stdin_used+0x20>	xmm0=rip+0xe89=1.2
    1196:	00 
    1197:	48 8b 05 8a 0e 00 00 	mov    0xe8a(%rip),%rax        # 2028 <_IO_stdin_used+0x28>		rax=rip+0xe8a=3.4
    119e:	66 0f 28 c8          	movapd %xmm0,%xmm1			// xmm1=xmm0=1.2
    11a2:	66 48 0f 6e c0       	movq   %rax,%xmm0			// xmm0=rax=3.4
    11a7:	e8 9d ff ff ff       	callq  1149 <f>				// f(xmm0, xmm1)
    11ac:	48 8d 3d 55 0e 00 00 	lea    0xe55(%rip),%rdi        # 2008 <_IO_stdin_used+0x8>	rdi=rip+0xe55
    11b3:	b8 01 00 00 00       	mov    $0x1,%eax			// eax=1
    11b8:	e8 93 fe ff ff       	callq  1050 <printf@plt>	// printf(rdi, xmm0)
    11bd:	b8 00 00 00 00       	mov    $0x0,%eax
    11c2:	5d                   	pop    %rbp
    11c3:	c3                   	retq   
    11c4:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    11cb:	00 00 00 
    11ce:	66 90                	xchg   %ax,%ax

  [16] .text             PROGBITS         0000000000001060  00001060
       00000000000001e5  0000000000000000  AX       0     0     16
  [17] .fini             PROGBITS         0000000000001248  00001248
       000000000000000d  0000000000000000  AX       0     0     4
  [18] .rodata           PROGBITS         0000000000002000  00002000
       0000000000000030  0000000000000000   A       0     0     8
  [19] .eh_frame_hdr     PROGBITS         0000000000002030  00002030
       000000000000004c  0000000000000000   A       0     0     4

/*
 * arm
 */
000000000040055c <f>:
  40055c:	d10043ff 	sub	sp, sp, #0x10
  400560:	fd0007e0 	str	d0, [sp, #8]
  400564:	fd0003e1 	str	d1, [sp]
  400568:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  40056c:	911a2000 	add	x0, x0, #0x688
  400570:	fd400000 	ldr	d0, [x0]
  400574:	fd4007e1 	ldr	d1, [sp, #8]
  400578:	1e601821 	fdiv	d1, d1, d0
  40057c:	fd4003e0 	ldr	d0, [sp]
  400580:	b203e7e0 	mov	x0, #0x6666666666666666    	// #7378697629483820646
  400584:	f2e80200 	movk	x0, #0x4010, lsl #48
  400588:	9e670002 	fmov	d2, x0
  40058c:	1e620800 	fmul	d0, d0, d2
  400590:	1e602820 	fadd	d0, d1, d0
  400594:	910043ff 	add	sp, sp, #0x10
  400598:	d65f03c0 	ret

000000000040059c <main>:
  40059c:	a9bf7bfd 	stp	x29, x30, [sp, #-16]!
  4005a0:	910003fd 	mov	x29, sp
  4005a4:	b200e7e0 	mov	x0, #0x3333333333333333    	// #3689348814741910323
  4005a8:	f2e80160 	movk	x0, #0x400b, lsl #48
  4005ac:	9e670001 	fmov	d1, x0
  4005b0:	b200e7e0 	mov	x0, #0x3333333333333333    	// #3689348814741910323
  4005b4:	f2e7fe60 	movk	x0, #0x3ff3, lsl #48
  4005b8:	9e670000 	fmov	d0, x0
  4005bc:	97ffffe8 	bl	40055c <f>
  4005c0:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  4005c4:	911a4000 	add	x0, x0, #0x690
  4005c8:	97ffffa2 	bl	400450 <printf@plt>
  4005cc:	52800000 	mov	w0, #0x0                   	// #0
  4005d0:	a8c17bfd 	ldp	x29, x30, [sp], #16
  4005d4:	d65f03c0 	ret

#endif

